}
}
-static void
-test_parse_declarations (void)
-{
- GtkCssProvider *provider;
- GError *error;
- gboolean res;
- gint i;
- const gchar *valid[] = {
- "* {}",
- "* { font: Sans 15 }",
- "* { font: Sans 15; }",
- "* { font: bold }",
- "* { color: red }",
- "* { /* just a comment */ }",
- "* { /* multi\nline\ncomment */ }",
- "* { font: /* comment here */ Sans 15 }",
- "* { color: red; background-color: shade (@bg_color, 0.5) }",
- "* { margin: 5 }",
- "* { margin: 5 10 }",
- "* { margin: 5 10 3 }",
- "* { margin: 5 10 3 5 }",
- "* { padding: 5 }",
- "* { padding: 5 10 }",
- "* { border-width: 5; border-radius: 10 }",
- "* { border-color: #ff00ff }",
- "* { engine: clearlooks }",
- "* { background-image: -gtk-gradient (linear, \n"
- " left top, right top, \n"
- " from (#fff), to (#000)) }",
- "* { background-image: -gtk-gradient (linear, \n"
- " 0.0 0.5, 0.5 1.0, \n"
- " from (#fff), \n"
- " color-stop (0.5, #f00),\n"
- " to (#000)) }",
- "* { background-image: -gtk-gradient (radial, \n"
- " center center, 0.2, \n"
- " center center, 0.8, \n"
- " color-stop (0.0,#fff),\n"
- " color-stop (1.0,#000))}\n",
- "* { border-image: url(\"" SRCDIR "/test.png\") 3 4 3 4 stretch }",
- "* { border-image: url(\"" SRCDIR "/test.png\") 3 4 3 4 repeat stretch}",
- "* { transition: 150ms ease-in-out }",
- "* { transition: 1s linear loop }",
- NULL
- };
-
- const gchar *invalid[] = {
- "* { color }",
- "* { color:green; color }",
- "* { color:red; color; color:green }",
- "* { color:green; color: }",
- "* { color:red; color:; color:green }",
- "* { color:green; color{;color:maroon} }",
- "* { color:red; color{;color:maroon}; color:green }",
- "* { content: 'Hello",
- NULL
- };
-
- error = NULL;
- for (i = 0; valid[i]; i++)
- {
- provider = gtk_css_provider_new ();
- res = gtk_css_provider_load_from_data (provider, valid[i], -1, &error);
- if (error)
- g_print ("parsing '%s': got unexpected error: %s\n", valid[i], error->message);
- g_assert_no_error (error);
- g_assert (res);
-
- g_object_unref (provider);
- }
-
- for (i = 0; invalid[i]; i++)
- {
- provider = gtk_css_provider_new ();
- res = gtk_css_provider_load_from_data (provider, invalid[i], -1, &error);
- g_assert_error (error, GTK_CSS_PROVIDER_ERROR, GTK_CSS_PROVIDER_ERROR_FAILED);
- g_assert (!res);
- g_object_unref (provider);
- g_clear_error (&error);
- }
-}
-
static void
test_path (void)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/style/parse/selectors", test_parse_selectors);
- g_test_add_func ("/style/parse/declarations", test_parse_declarations);
g_test_add_func ("/style/path", test_path);
g_test_add_func ("/style/match", test_match);
g_test_add_func ("/style/style-property", test_style_property);
declarations.css \
declarations.errors \
declarations.ref.css \
+ declarations-invalid-01.css \
+ declarations-invalid-01.errors \
+ declarations-invalid-01.ref.css \
+ declarations-invalid-02.css \
+ declarations-invalid-02.errors \
+ declarations-invalid-02.ref.css \
+ declarations-invalid-03.css \
+ declarations-invalid-03.errors \
+ declarations-invalid-03.ref.css \
+ declarations-invalid-04.css \
+ declarations-invalid-04.errors \
+ declarations-invalid-04.ref.css \
+ declarations-invalid-05.css \
+ declarations-invalid-05.errors \
+ declarations-invalid-05.ref.css \
+ declarations-invalid-06.css \
+ declarations-invalid-06.errors \
+ declarations-invalid-06.ref.css \
+ declarations-invalid-07.css \
+ declarations-invalid-07.errors \
+ declarations-invalid-07.ref.css \
+ declarations-invalid-08.css \
+ declarations-invalid-08.errors \
+ declarations-invalid-08.ref.css \
+ declarations-valid-01.css \
+ declarations-valid-01.ref.css \
+ declarations-valid-02.css \
+ declarations-valid-02.ref.css \
+ declarations-valid-03.css \
+ declarations-valid-03.ref.css \
+ declarations-valid-04.css \
+ declarations-valid-04.ref.css \
+ declarations-valid-05.css \
+ declarations-valid-05.ref.css \
+ declarations-valid-06.css \
+ declarations-valid-06.ref.css \
+ declarations-valid-07.css \
+ declarations-valid-07.ref.css \
+ declarations-valid-08.css \
+ declarations-valid-08.ref.css \
+ declarations-valid-09.css \
+ declarations-valid-09.ref.css \
+ declarations-valid-10.css \
+ declarations-valid-10.ref.css \
+ declarations-valid-11.css \
+ declarations-valid-11.ref.css \
+ declarations-valid-12.css \
+ declarations-valid-12.ref.css \
+ declarations-valid-13.css \
+ declarations-valid-13.ref.css \
+ declarations-valid-14.css \
+ declarations-valid-14.ref.css \
+ declarations-valid-15.css \
+ declarations-valid-15.ref.css \
+ declarations-valid-16.css \
+ declarations-valid-16.ref.css \
+ declarations-valid-17.css \
+ declarations-valid-17.ref.css \
+ declarations-valid-18.css \
+ declarations-valid-18.errors \
+ declarations-valid-18.ref.css \
+ declarations-valid-19.css \
+ declarations-valid-19.ref.css \
+ declarations-valid-20.css \
+ declarations-valid-20.ref.css \
+ declarations-valid-21.css \
+ declarations-valid-21.ref.css \
+ declarations-valid-22.css \
+ declarations-valid-22.ref.css \
+ declarations-valid-23.css \
+ declarations-valid-23.ref.css \
+ declarations-valid-24.css \
+ declarations-valid-24.ref.css \
+ declarations-valid-25.css \
+ declarations-valid-25.ref.css \
does-not-exist.css \
does-not-exist.errors \
does-not-exist.ref.css \
--- /dev/null
+* { color }
--- /dev/null
+declarations-invalid-01.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* { color:green; color }
--- /dev/null
+declarations-invalid-02.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* {
+ color: rgb(0,255,0);
+}
--- /dev/null
+* { color:red; color; color:green }
--- /dev/null
+declarations-invalid-03.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* {
+ color: rgb(0,255,0);
+}
--- /dev/null
+* { color:green; color: }
--- /dev/null
+declarations-invalid-04.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* {
+ color: rgb(0,255,0);
+}
--- /dev/null
+* { color:red; color:; color:green }
--- /dev/null
+declarations-invalid-05.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* {
+ color: rgb(0,255,0);
+}
--- /dev/null
+* { color:green; color{;color:maroon} }
--- /dev/null
+declarations-invalid-06.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* {
+ color: rgb(0,255,0);
+}
--- /dev/null
+* { color:red; color{;color:maroon}; color:green }
--- /dev/null
+declarations-invalid-07.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* {
+ color: rgb(0,255,0);
+}
--- /dev/null
+* { content: 'Hello
--- /dev/null
+declarations-invalid-08.css:1: error: GTK_CSS_PROVIDER_ERROR_NAME
+declarations-invalid-08.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
+declarations-invalid-08.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* { font: Sans 15 }
--- /dev/null
+* {
+ font-family: "Sans";
+ font-size: 15;
+ font-style: normal;
+ font-variant: normal;
+ font-weight: normal;
+}
--- /dev/null
+* { font: Sans 15; }
--- /dev/null
+* {
+ font-family: "Sans";
+ font-size: 15;
+ font-style: normal;
+ font-variant: normal;
+ font-weight: normal;
+}
--- /dev/null
+* { font: bold }
--- /dev/null
+* {
+ font-family: "Sans";
+ font-size: 10;
+ font-style: normal;
+ font-variant: normal;
+ font-weight: bold;
+}
--- /dev/null
+* { color: red }
--- /dev/null
+* {
+ color: rgb(255,0,0);
+}
--- /dev/null
+* { /* just a comment */ }
--- /dev/null
+* { /* multi
+line
+comment */ }
--- /dev/null
+* { font: /* comment here */ Sans 15 }
--- /dev/null
+* {
+ font-family: "Sans";
+ font-size: 15;
+ font-style: normal;
+ font-variant: normal;
+ font-weight: normal;
+}
--- /dev/null
+* { color: red; background-color: shade (@bg_color, 0.5) }
--- /dev/null
+* {
+ background-color: shade (@bg_color, 0.5);
+ color: rgb(255,0,0);
+}
--- /dev/null
+* { margin: 5 }
--- /dev/null
+* {
+ margin-bottom: 5;
+ margin-left: 5;
+ margin-right: 5;
+ margin-top: 5;
+}
--- /dev/null
+* { margin: 5 10 }
--- /dev/null
+* {
+ margin-bottom: 5;
+ margin-left: 10;
+ margin-right: 10;
+ margin-top: 5;
+}
--- /dev/null
+* { margin: 5 10 3 }
--- /dev/null
+* {
+ margin-bottom: 3;
+ margin-left: 10;
+ margin-right: 10;
+ margin-top: 5;
+}
--- /dev/null
+* { margin: 5 10 3 5 }
--- /dev/null
+* {
+ margin-bottom: 3;
+ margin-left: 5;
+ margin-right: 10;
+ margin-top: 5;
+}
--- /dev/null
+* { padding: 5 }
--- /dev/null
+* {
+ padding-bottom: 5;
+ padding-left: 5;
+ padding-right: 5;
+ padding-top: 5;
+}
--- /dev/null
+* { padding: 5 10 }
--- /dev/null
+* {
+ padding-bottom: 5;
+ padding-left: 10;
+ padding-right: 10;
+ padding-top: 5;
+}
--- /dev/null
+* { border-width: 5; border-radius: 10 }
--- /dev/null
+* {
+ border-bottom-left-radius: 10;
+ border-bottom-right-radius: 10;
+ border-bottom-width: 5;
+ border-left-width: 5;
+ border-right-width: 5;
+ border-top-left-radius: 10;
+ border-top-right-radius: 10;
+ border-top-width: 5;
+}
--- /dev/null
+* { border-color: #ff00ff }
--- /dev/null
+* {
+ border-bottom-color: rgb(255,0,255);
+ border-left-color: rgb(255,0,255);
+ border-right-color: rgb(255,0,255);
+ border-top-color: rgb(255,0,255);
+}
--- /dev/null
+* { engine: definitelydoesnotexist }
--- /dev/null
+declarations-valid-18.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
--- /dev/null
+* { background-image: -gtk-gradient (linear,
+ left top, right top,
+ from (#fff), to (#000)) }
--- /dev/null
+* {
+ background-image: -gtk-gradient (linear, left top, right top, from (rgb(255,255,255)), to (rgb(0,0,0)));
+}
--- /dev/null
+* { background-image: -gtk-gradient (linear,
+ 0.0 0.5, 0.5 1.0,
+ from (#fff),
+ color-stop (0.5, #f00),
+ to (#000)) }
--- /dev/null
+* {
+ background-image: -gtk-gradient (linear, left center, center bottom, from (rgb(255,255,255)), color-stop (0.5, rgb(255,0,0)), to (rgb(0,0,0)));
+}
--- /dev/null
+* { background-image: -gtk-gradient (radial,
+ center center, 0.25,
+ center center, 0.75,
+ color-stop (0.0,#fff),
+ color-stop (1.0,#000))}
+
--- /dev/null
+* {
+ background-image: -gtk-gradient (radial, center center, 0.25, center center, 0.75, from (rgb(255,255,255)), to (rgb(0,0,0)));
+}
--- /dev/null
+* { border-image: url("./test.png") 3 4 3 4 stretch }
--- /dev/null
+* {
+ border-image-repeat: stretch;
+ border-image-slice: 3 4;
+ border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABmJLR0QA/wD/AP+gvaeTAAAAFUlEQVQImQXBAQEAAACAEP9PF1CpMCnkBftPnd1xAAAAAElFTkSuQmCC");
+ border-image-width: none;
+}
--- /dev/null
+* { border-image: url("./test.png") 3 4 3 4 repeat stretch}
--- /dev/null
+* {
+ border-image-repeat: repeat stretch;
+ border-image-slice: 3 4;
+ border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABmJLR0QA/wD/AP+gvaeTAAAAFUlEQVQImQXBAQEAAACAEP9PF1CpMCnkBftPnd1xAAAAAElFTkSuQmCC");
+ border-image-width: none;
+}
--- /dev/null
+* { transition: 150ms ease-in-out }
--- /dev/null
+* {
+ transition: 150ms ease-in-out;
+}
--- /dev/null
+* { transition: 1s linear loop }
--- /dev/null
+* {
+ transition: 1s linear loop;
+}